<html>
<head><meta charset="utf-8"><title>pub(macro) · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html">pub(macro)</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212566878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212566878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ethan Brierley <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212566878">(Oct 07 2020 at 14:33)</a>:</h4>
<p>Hi, I'm new here and looking to start contributing to rustc. I was talking to <span class="user-mention" data-user-id="216206">@lcnr</span>  , who has been helping me, about a feature I was thinking about and he said that this stream would be a good place to ask for initial feedback.</p>
<p>This idea came from this line of code from the <code>log</code> crate <a href="https://github.com/rust-lang/log/blob/master/src/lib.rs#L1441">https://github.com/rust-lang/log/blob/master/src/lib.rs#L1441</a></p>
<p>With my feature</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// WARNING: this is not part of the crate's public API and is subject to change at any time</span>
<span class="cp">#[doc(hidden)]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">__private_api_log</span><span class="p">(</span><span class="w"></span>
</code></pre></div>

<p>would become</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">pub</span><span class="p">(</span><span class="kr">macro</span><span class="p">)</span><span class="w"> </span><span class="k">fn</span> <span class="nf">log</span><span class="p">(</span><span class="w"></span>
</code></pre></div>

<p>Functions marked <code>pub(macro)</code> would only be callable in macros defined in the same crate.</p>
<p><span class="user-mention" data-user-id="216206">@lcnr</span>  suggested tagging <span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span>  as they have experience with privacy related code. Maybe you could help me with some pointers if and when if I try implementing this?</p>



<a name="212567140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212567140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212567140">(Oct 07 2020 at 14:35)</a>:</h4>
<p>rfc ?</p>



<a name="212567541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212567541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ethan Brierley <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212567541">(Oct 07 2020 at 14:38)</a>:</h4>
<p><span class="user-mention" data-user-id="209117">@lzutao</span> I don't have an RFC. Are you saying I should create one?</p>



<a name="212567882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212567882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212567882">(Oct 07 2020 at 14:41)</a>:</h4>
<p>I expect that personally. However I'm not a T-lang member, they will answer this.</p>



<a name="212571007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212571007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212571007">(Oct 07 2020 at 15:00)</a>:</h4>
<p>afaik with the introduction of MCP and project groups, this does not seem to warrant an RFC at this stage</p>



<a name="212571101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212571101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212571101">(Oct 07 2020 at 15:00)</a>:</h4>
<p>Yeah, this just needs a project proposal.</p>



<a name="212571205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212571205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212571205">(Oct 07 2020 at 15:01)</a>:</h4>
<p>It's an interesting idea.</p>



<a name="212571504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212571504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212571504">(Oct 07 2020 at 15:03)</a>:</h4>
<p>Long-term, I think hygienic macros might not even need pub(macro), they could just access private functions from where they were defined.</p>
<p>But hygienic macros are a long way off, and this might be a good incremental step.</p>



<a name="212571759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212571759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212571759">(Oct 07 2020 at 15:04)</a>:</h4>
<p>Ideally, I would suggest talking to some compiler folks about how feasible either of those two options (accessing private functions, or pub(macro)) would be to implement. Because as a lang team member that'd be the first question on my mind.</p>



<a name="212572263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212572263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212572263">(Oct 07 2020 at 15:08)</a>:</h4>
<p>related: <a href="https://github.com/rust-lang/rfcs/pull/2968">https://github.com/rust-lang/rfcs/pull/2968</a></p>



<a name="212575784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212575784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212575784">(Oct 07 2020 at 15:28)</a>:</h4>
<p>From what I have seen <code>pub(macro)</code> shouldn't be that difficult, accessing amy private function might have a perf impact depending on how we implement it <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> I am not an expert here though</p>



<a name="212582070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/pub%28macro%29/near/212582070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ethan Brierley <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/pub(macro).html#212582070">(Oct 07 2020 at 16:11)</a>:</h4>
<p>I've opened an MCP <a href="https://github.com/rust-lang/lang-team/issues/59">https://github.com/rust-lang/lang-team/issues/59</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>